package com.example.noactivityresult;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

import androidx.activity.result.contract.ActivityResultContract;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class SecondActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_secord);

        String str = getIntent().getStringExtra("str");
        Toast.makeText(this, "收到:" + str, Toast.LENGTH_SHORT).show();
        findViewById(R.id.close).setOnClickListener(v -> {
            setResult(RESULT_OK, new Intent().putExtra("result", "哈哈哈"));
            finish();
        });
    }

}